// ADCardBase.h: interface for the CADCardBase class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_ADCARDBASE_H__37E9E7D5_88A1_4C4F_B069_597F0D583C16__INCLUDED_)
#define AFX_ADCARDBASE_H__37E9E7D5_88A1_4C4F_B069_597F0D583C16__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include ".\\Include\\Driver.h"

typedef struct _USERSETTING
{
    _USERSETTING()
    {
        m_dwPacerRate = 100;                // pacer rate
        m_ulConvNum = 100;                  // conversion number
        m_wStartChl = 0;
        m_wStopChl = 0;     // scan channels
        m_wDataType = 1;                    // display type : FLOAT(1)
        m_wEvtFlag = 1;                     // event enable(0)
        m_wFifoEnable = 0;                  // Fifo disable(0)
        m_wFifoSize = 1024;
        
        m_wGainList = 0;      // gain list flag
        m_dwStartPt = 0; 
        m_dwStopPt = 99;   // display points
        m_wExtTrig = 0;       // external or internal trigger
        
        m_wCyclicMode = 0;    // cyclic or non-cyclic mode
        m_wBufferMode = 0;    // buffer: single or double
        m_wIntrCount = 1;
        m_wCyclicCount = 0;    // number of cyclic count
		m_wGainCode = 0;

    }
    DWORD  m_dwPacerRate;                // pacer rate
    ULONG  m_ulConvNum;                  // conversion number
    USHORT m_wStartChl;
    USHORT m_wStopChl;     // scan channels
    USHORT m_wDataType;                    // display type : FLOAT(1)
    USHORT m_wEvtFlag;                     // event enable(0)
    USHORT m_wFifoEnable;                  // Fifo disable(0)
    USHORT m_wFifoSize;
    
    USHORT m_wGainList;      // gain list flag
    ULONG  m_dwStartPt; 
    ULONG  m_dwStopPt;   // display points
    USHORT m_wExtTrig;       // external or internal trigger
    
    USHORT m_wCyclicMode;    // cyclic or non-cyclic mode
    USHORT m_wBufferMode;    // buffer: single or double
    USHORT m_wIntrCount;
    USHORT m_wCyclicCount;    // number of cyclic count
	USHORT m_wGainCode;
	HGLOBAL hBuf;
	HGLOBAL hUserBuf;
}USERSETTING, *PUSERSETTING;

typedef struct _FAICHECKVALUE
{
	_FAICHECKVALUE()
	{
		m_wActiveBuf = 0;
		m_wOverrun = 0;
		m_wStopped = 0;
		m_ulRetrieved = 0;
		m_wHalfReady = 0;
	}

	USHORT m_wActiveBuf ;
	USHORT m_wOverrun ;
	USHORT m_wStopped ;
	ULONG m_ulRetrieved ;
	USHORT m_wHalfReady ;

}FAICHECKVALUE, *PFAICHECKVALUE;

class CADCardBase  
{
public:
	CADCardBase();
    CADCardBase(ULONG devicenum);
	virtual ~CADCardBase();
    USERSETTING m_sUserSetting;
    BOOL OpenDASCard();
    BOOL GetDeviceFeatures(LPDEVFEATURES lpdevfeatures);
	BOOL PrepareTransPara(LPT_FAIIntStart pfaiintstart, LPT_FAITransfer pfaitransfer);
	BOOL InitEventFeature();

	static UINT ADTransThread(LPVOID pParam);
	void adInterruptEvent();
	void adBufChangeEvent();
	void adOverrunEvent();
	void adTerminateEvent();

	///
	void StartADTransInt();
	void StopADTransInt();

//protected:
    ULONG  m_dwDeviceNum; 
    LONG   m_hDriverHandle;
    DEVFEATURES m_DevFeatures;
	PT_FAIIntStart m_ptFAIIntStart;
	PT_FAITransfer m_ptFAITransfer;
	PT_EnableEvent m_ptEnableEvent;
	PT_CheckEvent  m_ptCheckEvent;
	PT_FAICheck    m_ptFAICheck;
	FAICHECKVALUE  m_FAICheckValue;
	

};

#endif // !defined(AFX_ADCARDBASE_H__37E9E7D5_88A1_4C4F_B069_597F0D583C16__INCLUDED_)
